package com.foodchain.consts;

import java.util.HashMap;
import java.util.Map;

public final class Code {

    private Code() {}

    /* 用户状态：正常|锁定|异常|作废 */
    public static final class UserState {

        private UserState() {}

        public static final String NORMAL = "NORMAL";

        public static final String LOCKED = "LOCKED";

        public static final String ERROR = "ERROR";

        public static final String INVALID = "INVALID";

        public static final Map<String, String> CODE_MAP = new HashMap<String, String>();
        static {
            CODE_MAP.put(NORMAL, "正常");
            CODE_MAP.put(LOCKED, "锁定");
            CODE_MAP.put(ERROR, "异常");
            CODE_MAP.put(INVALID, "作废");
        }

        public static final String get(String code) { return getMap(CODE_MAP, code); }

    }

    /* 证件类型：身份证|护照|驾驶证 */
    public static final class CardType {

        private CardType () {}

        public static final String ID_CARD = "ID_CARD";

        public static final String PASSPORT = "PASSPORT";

        public static final String DRIVING_LICENSE = "DRIVING_LICENSE";

        public static final Map<String, String> CODE_MAP = new HashMap<>();
        static {
            CODE_MAP.put(ID_CARD, "身份证");
            CODE_MAP.put(PASSPORT, "护照");
            CODE_MAP.put(DRIVING_LICENSE, "驾驶证");
        }

        public static final String get(String code) {
            return getMap(CODE_MAP, code);
        }

    }

    /* 实名认证状态：已认证|未认证|审核中|认证失败 */
    public static final class VerifyState {

        private VerifyState () {}

        public static final String VERIFIED = "VERIFIED";

        public static final String UN_VERIFY = "UN_VERIFY";

        public static final String VERIFYING = "VERIFYING";

        public static final String VERIFY_FAIL = "VERIFY_FAIL";

        public static final Map<String, String> CODE_MAP = new HashMap<String, String>();
        static {
            CODE_MAP.put(VERIFIED, "已认证");
            CODE_MAP.put(UN_VERIFY, "未认证");
            CODE_MAP.put(VERIFYING, "审核中");
            CODE_MAP.put(VERIFY_FAIL, "认证失败");
        }

        public static final String get(String code) {
            return getMap(CODE_MAP, code);
        }

    }

    /* 邮箱验证：已验证|未验证 */
    public static final class EmailVerifyState {

        private EmailVerifyState () {}

        public static final String VERIFIED = "VERIFIED";

        public static final String UNVERIFY = "UNVERIFY";

        public static final Map<String, String> CODE_MAP = new HashMap<String, String>();
        static {
            CODE_MAP.put(VERIFIED, "已验证");
            CODE_MAP.put(UNVERIFY, "未验证");
        }

        public static final String get(String code) {
            return getMap(CODE_MAP, code);
        }

    }

    /* 日志操作方：管理员|用户本人 */
    public static final class OperateAspect {

        private OperateAspect () {}

        public static final String MANAGER = "MANAGER";

        public static final String USER = "USER";

        public static final Map<String, String> CODE_MAP = new HashMap<String, String>();
        static {
            CODE_MAP.put(MANAGER, "管理员");
            CODE_MAP.put(USER, "用户");
        }

        public static final String get(String code) { return getMap(CODE_MAP, code); }

    }

    public static final class NotifyType {

        private NotifyType() {}

        public static final String VALIDATE_CODE = "VALIDATE_CODE";

        public static final String STATUS_CHANGED = "STATUS_CHANGED";

        private static final Map<String, String> CODE_MAP = new HashMap<String, String>();
        static {
            CODE_MAP.put(VALIDATE_CODE, "验证码");
            CODE_MAP.put(STATUS_CHANGED, "状态变更");
        }

        public static final String get(String code) {
            return getMap(CODE_MAP, code);
        }
    }

    /* 新闻类型：新闻公告|注册协议|投票规则 */
    public static final class NewsType {

        private NewsType () {}

        public static final String NEWS_BULLETIN = "news_bulletin";

        public static final String REGISTER_AGREEMENT = "register_agreement";

        public static final String VOTE_RULE = "vote_rule";

        public static final String PLATFORM_NOTICE = "platform_notice";

        public static final Map<String, String> CODE_MAP = new HashMap<String, String>();
        static {
            CODE_MAP.put(NEWS_BULLETIN, "新闻公告");
            CODE_MAP.put(REGISTER_AGREEMENT, "注册协议");
            CODE_MAP.put(VOTE_RULE, "投票规则");
            CODE_MAP.put(PLATFORM_NOTICE, "平台公告");
        }

        public static final String get(String code) { return getMap(CODE_MAP, code); }

    }

    /* 活动状态：报名中|进行中|已结束 */
    public static final class ActivityStatus {

        private ActivityStatus () {}

        public static final String SIGNING = "1";

        public static final String HAVING = "2";

        public static final String END = "3";

        public static final Map<String, String> CODE_MAP = new HashMap<String, String>();
        static {
            CODE_MAP.put(SIGNING, "报名中");
            CODE_MAP.put(HAVING, "进行中");
            CODE_MAP.put(END, "已结束");
        }

        public static final String get(String code) { return getMap(CODE_MAP, code); }

    }

    private static final String getMap(Map<String, String> map, String code) {
        if (map.containsKey(code)) {
            return map.get(code);
        }
        return "";
    }
}
